const { body } = require("express-validator");
const validation = require("./errorBack");
const { Store } = require("../model/index");

module.exports.storeValidator = validation([
  body("title").custom(async (val) => {
    console.log(val);
    const dbback = await Store.findOne({ title: val });
    if (dbback) {
      return Promise.reject("知识库已存在");
    }
  }),
]);
